<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="header.jsp"%>
<html>
<head>
  <title>restful方式传递</title>
  <%--    引入jquery的js组件
          和json转化js文件
          --%>
  <script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
  <script type="text/javascript" src="static/js/jquery.json.js"></script>
  <script>
    /*页面加载完成之后需要执行的代码*/
    $(function () {

      //根据名称查询学生
      $('#btn05').click(function () {

        /*发送Ajax请求*/
        $.ajax({
          type: "GET",
          url: "students/all/张三/18/4578",
          success: function(msg){
            console.info(msg);
          }
        });
      });


      //根据ID查询数据
      $('#btn04').click(function () {

        /*发送Ajax请求*/
        $.ajax({
          type: "GET",
          url: "students/1",
          success: function(msg){
            console.info(msg);
          }
        });
      });

      //删除
      $('#btn03').click(function () {

        /*发送Ajax请求*/
        $.ajax({
          type: "DELETE",
          url: "students/1",
          success: function(msg){
            console.info(msg);
          }
        });
      });

      //修改
      $('#btn02').click(function () {

        /*发送Ajax请求*/
        $.ajax({
          type: "PUT",
          url: "students/1",
          data: {
            stuName:"一护",
            stuNo:"4578",
            age:"50"
          },
          success: function(msg){
            console.info(msg);
          }
        });
      });




      //新增
      $('#btn01').click(function () {

        /*发送Ajax请求*/
        $.ajax({
          type: "POST",
          url: "students/more",
          data: {
            stuName:"一护",
            stuNo:"4578",
            age:"50"
          },
          success: function(msg){
            console.info(msg);
          }
        });
      });


    });
  </script>
</head>
<body>

<button id="btn01">新增学生</button>
<button id="btn02">修改学生</button>
<button id="btn03">删除学生</button>
<button id="btn04">根据ID查询学生</button>
<button id="btn05">根据名称查询学生</button>

</body>
</html>
